<script>
	import {loginRecords} from '@/api/api.js'
	export default {
		onLaunch: function() {
			let todayLoginedKey = uni.getStorageSync('userTodayLoginedKey') || null
			let userInfo = uni.getStorageSync('ftxUserInfo') || null
			let timestamp = uni.$lv.date.getTimestamp()
			let today = uni.$lv.date.format(timestamp, "yyyy-mm-dd")
			// 今天未登录过
			if ( userInfo != null &&  todayLoginedKey != today ) {
				uni.getSystemInfo({
					success(res) {
						let _record = {
							deviceBrand: res.deviceBrand || '',
							deviceId: res.deviceId || '',
							deviceType: res.deviceType || '',
							osName: res.osName || '',
							osVersion: res.osVersion || '',
						}
						loginRecords(_record).then(_ => {
							uni.setStorageSync('userTodayLoginedKey',today)
						})
					}
				})
			}
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "@/uni_modules/uview-ui/index.scss";
	@import "@/uni_modules/uview-ui/libs/css/flex.scss";
	
	page {
		background-color: #FFFFFF;
		font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
	}
	.white-bg {
		background-color: #FFFFFF;
	}
	/*每个页面公共css */
	.flex {
		@include flex;
		display: flex;
	}
	.mr-20{margin-right: 20rpx;}
	.ellipsis {
		display: flex;
		overflow: hidden;
	}
	
	.uni-ellipsis-1 {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	
	.uni-ellipsis-2 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.content-padding {
		padding: $uni-content-padding;
	}
	.padding-l-r {
		padding: 0 30rpx;
	}
	.buy-button {
		background-color: $uni-bg-color-light;
		color: #FFFFFF;
		padding: 20rpx 30rpx;
		border-radius: 10rpx;
		font-size: 34rpx;
	}
	/** 价格之间连接的加号 */
	.plus {
		font-size: 46rpx;
		margin: 0 10rpx;
		color: $uni-text-color-placeholder;
	}
	.price-item {
		@include flex;
		justify-content: baseline;
		align-items: baseline;
		.price {
			font-size: 44rpx;
			font-weight: bold;
			color: $uni-price-color;
		}
		.unit {
			font-size: 28rpx;
			margin-left: 6rpx;
			color: $uni-text-color-placeholder;
		}
	}
	.popup-page {
		height: calc(100vh - 44px);
		background-color: #FFFFFF;
		&__title {
			@include flex;
			font-weight: bold;
			font-size: 32rpx;
			justify-content: center;
			align-items: center;
			height: 44px;
			border-bottom: 1px solid #E2E2E2;
		}
		&__content {
			margin-top: 20px;
			height: calc(100vh - 120px - 66px);
			padding: 0px 15px;
		}
		&__footer {
			@include flex;
			justify-content: space-between;
			align-items: center;
			width: 710rpx;
			height: 66px;
			border-top: 1px solid #E2E2E2;
			background-color: #fff;
			position: fixed;
			bottom: 0;
			padding: 0 20rpx;
		}
	}
</style>
